﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EmpUpt.aspx.cs" Inherits="FPC.Offer.UI.MangerEmp.EmpUpt" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="..//favicon.ico">
    <link rel="Shortcut Icon" href="..//favicon.ico" />
    <link href="../H-ui/static/h-ui/css/H-ui.min.css" rel="stylesheet" />
    <link href="../H-ui/static/h-ui.admin/css/H-ui.admin.css" rel="stylesheet" />
    <link href="../H-ui/Lib/Hui-iconfont/1.0.8/iconfont.css" rel="stylesheet" />
    <link href="../H-ui/static/h-ui.admin/skin/default/skin.css" rel="stylesheet" />
    <link href="../H-ui/static/h-ui.admin/css/style.css" rel="stylesheet" />
    <link href="../H-ui/Lib/layer/2.4/skin/layer.css" rel="stylesheet" />
    <title>修改用户 - H-ui.admin v3.0</title>
    <meta name="keywords" content="H-ui.admin v3.0,H-ui网站后台模版,后台模版下载,后台管理系统模版,HTML后台模版下载">
    <meta name="description" content="H-ui.admin v3.0，是一款由国人开发的轻量级扁平化网站后台模板，完全免费开源的网站后台管理系统模版，适合中小型CMS后台系统。">
</head>
        <!--_footer 作为公共模版分离出去-->
    <script src="../H-ui/Lib/jquery/1.9.1/jquery.min.js"></script>
    <script src="../H-ui/Lib/layer/2.4/layer.js"></script>
    <script src="../H-ui/static/h-ui/js/H-ui.js"></script>
    <script src="../H-ui/static/h-ui.admin/js/H-ui.admin.js"></script>
    <script src="../H-ui/Lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
    <script src="../H-ui/Lib/laypage/1.2/laypage.js"></script>
    <script src="../H-ui/Lib/jquery/jquery-form.js"></script>

    <script type="text/javascript">
        $(function () {

            var url = location.href;
            var index = url.indexOf("=");
            var id = url.substring(index + 1);


            /*页面加载同时把下拉框的值附上*/
            $(function () {
                $.ajax({
                    url: "../GeneralProcessor/MangerEmp/EmpManager.ashx",
                    type: "post",
                    data: {
                        Actioon: "<%=FPC.Offer.Common.EnumAction.Select %>",
                        name: "下拉"

                    },
                    success: function (n) {
                        var data = JSON.parse(n)
                        var role = [];
                        var Organize = [];
                        var dept = [];

                        //添加部门
                        $(data.lst1).each(function (i, item) {
                            dept.push("<option value=" + item.DeptId + " selected>" + item.OreganizeSublevelId + "</option>");
                        })
                        $("#dept").append(dept)

                        //添加角色
                        $(data.lst2).each(function (i, item) {
                            role.push("<option value=" + item.RoleId + " selected>" + item.RoleName + "</option>");
                        })
                        $("#role").append(role)

                        //添加公安局
                        $(data.lst3).each(function (i, item) {
                            Organize.push("<option value=" + item.OrganizeId + " selected>" + item.OrganizeName + "</option>");
                        })
                        $("#Organize").append(Organize)

                    }
                })
            })



            $.ajax({
                url: "../GeneralProcessor/MangerEmp/EmpManager.ashx",
                type: "post",
                data: {
                    Actioon: "<%=FPC.Offer.Common.EnumAction.Select %>",
                        id: id
                    },
                    success: function (n) {
                        var data = JSON.parse(n);

                        var name = $("#username").val(data.UserName);
                        var tel = $("#mobile").val(data.UserTel);
                        var email = $("#email").val(data.UserEmail);
                        var loginname = $("#loginname").val(data.LoginName);
                        var loginpwd = $("#loginpwd").val(data.LoginPwd);
                        var idcard = $("#idcard").val(data.UserCard);
                        var files = $("#file").val(data.UserPhoto);
                        //部门反填
                        var deptselected = document.getElementById("dept")
                        deptselected.selectedIndex = data.DeptId;
                        //角色反填
                        var roleselected = document.getElementById("role")
                        roleselected.selectedIndex = data.RoleId;
                        //公安局反填
                        var Organizeselected = document.getElementById("Organize")
                        Organizeselected.selectedIndex = data.OrganizeName;
                        //地址反填
                        var Cityselected = document.getElementById("select")
                        var m = 0;
                        switch (data.UserAddress)
                        {
                            case "": m = 0; break;
                            case "北京": m = 1; break;
                            case "上海": m = 2; break;
                            case "广州": m = 3; break;
                        }
                        Cityselected.selectedIndex = m;


                        switch (data.UserSex) {
                            case "1": $(":radio[value=1]").attr("checked", "checked"); break;
                            case "2": $(":radio[value=2]").attr("checked", "checked"); break;
                            case "3": $(":radio[value=3]").attr("checked", "checked"); break;
                            default: break;
                        }
                        var workstateselected = document.getElementById("workstate")
                        var n = 0;
                        switch (data.FuzzUserStates) {
                            case 0: n = 0; break;
                            case 1: n = 1; break;
                            case 2: n = 2; break;
                            case 3: n = 3; break;
                        }
                        workstateselected.selectedIndex = n;

                        var files = $("#file").val(data.UserPhoto);

                    }

            });
            $("#bt1").click(function () {
                var loginname = $("#loginname").val();
                var loginpwd = $("#loginpwd").val();
                var idcard = $("#idcard").val();
                var role = $("#role").val();
                var Organize = $("#Organize").val();
                var dept = $("#dept").val();
                var workstate = $("#workstate").val();
                var sex = parseInt($("input[name='sex']:checked").val());
                var name = $("#username").val();
                var tel = $("#mobile").val();
                var email = $("#email").val();
                var city = $("#select").val();
                var files = $("#file").val();

                //正则验证
                if (loginname == "") {
                    layer.alert("登陆账户不能为空！")
                }
                if (loginpwd == "") {
                    layer.alert("登陆密码户不能为空！");
                }
                var regpwd = /\w{8}/
                if (!regpwd.test(loginpwd)) {
                    layer.alert("密码应该为8位字母或数字组成");
                }
                if (idcard == "") {
                    layer.alert("身份证号不能为空！")
                }
                var regcard = /^\d{15}|\d{}18$ /;
                if (!regcard.test(idcard)) {
                    layer.alert("身份证号格式不对！");
                }
                if (nam == "") {
                    layer.alert("用户名不能为空！")
                }

                if (tel == "") {
                    layer.alert("手机号不能为空！")
                };
                var regtel = /1[3|5|7]^\d{9}/;
                if (!regtel.test(tel)) {
                    layer.alert("手机号格式不正确")
                }
                if (email == "") {
                    layer.alert("邮箱不能为空！")
                }
                var regemail = /^(\w)+(\.\w+)*@(\w)+((\.\w{2,3}){1,3})$/
                if (!regemail.test(email)) {
                    layer.alert("邮箱格式不正确")
                }
                if (files == "") {
                    layer.alert("照片不能为空！");
                }
                //变量接收ajax
                var option = {
                    url: "../GeneralProcessor/MangerEmp/EmpManager.ashx",
                    type: "post",
                    dataType: "json",
                    data: {
                        Actioon: "<%=FPC.Offer.Common.EnumAction.Update %>",
                        getid:id,
                        getname: name,
                        Getsex: sex,
                        gettel: tel,
                        getemail: email,
                        getcity: city,
                        getloginname: loginname,
                        getloginpwd: loginpwd,
                        getidcard: idcard,
                        getrole: role,
                        getOrganize: Organize,
                        getdept: dept,
                        getfiles: files,
                        getworkstate: workstate
                    },
                    success: function (n) {
                        if (n > 0) {
                            layer.alert('修改成功!');
                            location.href = "EmpManager.aspx";
                        }
                        else {
                            layer.alert('修改失败!')
                        }
                    }
                }

                $("#jvForm").ajaxSubmit(option)


            })
        })


    </script>

<body>
    <article class="page-container">
        <form  method="post" id="jvForm"  enctype="multipart/form-data" action="../GeneralProcessor/MangerEmp/EmpManager.ashx" id="form-member-add">
           <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>账户：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text"  placeholder="" id="loginname" name="username">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>密码：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text"  placeholder="" id="loginpwd" name="username">
            </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>用户名：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text"  placeholder="" id="username" name="username">
                </div>
            </div>
           <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">附件：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <span class="btn-upload form-group">
                        <a href="../javascript:void();" class="btn btn-primary radius upload-btn" ><i class="Hui-iconfont">&#xe642;</i> 上传相片</a>
                        <input type="file" id="file" multiple name="file-2" class="input-file">
                    </span>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>身份证号：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text"  placeholder="" id="idcard" name="username">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>性别：</label>
                <div class="formControls col-xs-8 col-sm-9 skin-minimal">
                    <div class="radio-box">
                        <input name="sex" type="radio" value="1" checked>
                        <label for="sex-1">男</label>
                    </div>
                    <div class="radio-box">
                        <input type="radio" id="sex-2" name="sex" value="2">
                        <label for="sex-2">女</label>
                    </div>
                    <div class="radio-box">
                        <input type="radio" id="sex-3" name="sex" value="3">
                        <label for="sex-3">保密</label>
                    </div>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>手机：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" value="" placeholder="" id="mobile" name="mobile">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>邮箱：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" placeholder="@" name="email" id="email">
                </div>
            </div>
             <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">角色：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <span class="select-box">
                        <select class="select" id="role" size="1" name="city">
                            <option value="0" selected>请分配角色</option>
                        </select>
                    </span>
                </div>
               </div>
             <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">所在派出所：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <span class="select-box">
                        <select class="select" id="Organize" size="1" name="city">
                            <option value="0" selected>请选择派出所</option>
                        </select>
                    </span>
                </div>
             <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">所在部门：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <span class="select-box">
                        <select class="select" id="dept" size="1" name="city">
                            <option value="0" selected>请选择部门</option>
                        </select>
                    </span>
                </div>
            </div>

            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">所在城市：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <span class="select-box">
                        <select class="select" id="select" size="1" name="city">
                            <option value="" selected>请选择城市</option>
                            <option value="北京">北京</option>
                            <option value="上海">上海</option>
                            <option value="广州">广州</option>
                        </select>
                    </span>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-3">工作状态：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <span class="select-box">
                        <select class="select" id="workstate" size="1" name="city">
                            <option value="0" selected>请选择</option>
                            <option value="1">在职</option>
                            <option value="2">请假</option>
                            <option value="3">退休</option>
                        </select>
                    </span>
                </div>
            </div>
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input class="btn btn-primary radius" type="button" id="bt1" onclick="upt()" value="&nbsp;&nbsp;修改&nbsp;&nbsp;">
                </div>
            </div>
        </form>
    </article>

</body>
</html>

